/*
	MIDAS Context Based Routing
	cbr_matrix.h
	Copyright (c) 2007 Radoslaw Olgierd Schoeneich
	MEAG IT PW
*/

#ifndef cbr_matrix_h_
#define cbr_matrix_h_

#include <algorithm>
#include "cbr_object.h"

/**
 * Two-dimensional square array.
 */

template<typename T>
class cbr_Matrix : private cbr_Object {
private:
	T *data;
	int size;

public:
	cbr_Matrix(int size)
	{
		this->size = size;
		this->data = new T[size * size];
	}

	~cbr_Matrix()
	{
		delete[] this->data;
	}

	int getSize() const { return size; }
	void fill(const T& value) { std::fill_n(data, size * size, value); }

	T* operator[](int x) { return this->data + this->size * x; }
};

#endif	// cbr_matrix_h_
